
<template>
  <basic-container >
    <avue-crud
      ref="crud"
      :data="tableData"
      :table-loading="tableLoading"
      :option="tableOption"
    >
    <template  slot="replyLimit" slot-scope="scope">
      <avue-input-number v-model="scope.row.replyLimit" precision="0" ></avue-input-number>
    </template>
    </avue-crud>
    <div style="text-align: center; margin: 40px">
      <template>
          <el-button
            :loading="uploading"
            type="primary"
            @click="handleSave"
          >确 定</el-button>
        <el-button @click="$emit('close')">关 闭</el-button>
      </template>
    </div>
  </basic-container>
</template>

<script>
import { mapGetters } from "vuex";

export default {
  name: "TempData",
  data () {
    return {
      searchForm: {},
      tableData: [],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 20, // 每页显示多少条
      },
      tableLoading: false,
      uploading: false,
    };
  },
  props: ["fetch", "tableOption", "query"],
  created () {

              this.page.currentPage = 1
              this.getList(this.page);
  },
  methods: {
    getList (page, params) {
      this.tableLoading = true;
      this.fetch({
        ...this.query
      })
        .then((response) => {
          this.tableData = response.data.data;
          this.tableLoading = false;
        })
        .catch(() => {
          this.tableLoading = false;
        });
    },

    handleSave () {
      this.$emit("save", this.tableData);
      this.getList(this.page);
    }
  },
};
</script>
